package com.buydeem.share.customjson.controller;

import com.buydeem.share.customjson.model.Order;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.math.BigDecimal;

/**
 * @author zengchao
 * @version 1.0.0
 * @ClassName OrderController.java
 * @Description TODO
 * @createTime 2021年06月23日 20:28:00
 */
@RestController
@RequestMapping("order")
public class OrderController {

    @GetMapping("/get")
    public Object getOrderInfo(@RequestParam("orderNo") String orderNo){
        Order order = new Order();
        order.setOrderNo(orderNo);
        order.setOrderAmount(new BigDecimal("100.05"));
        order.setDiscountAmount(new BigDecimal("10.00"));
        order.setDiscountPercent(order.getDiscountAmount().divide(order.getOrderAmount(),4,BigDecimal.ROUND_HALF_UP));
        return order;
    }
}
